VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form frmNewType 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Type management"
   ClientHeight    =   9045
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   10155
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   9045
   ScaleWidth      =   10155
   Begin MSComctlLib.ImageList ImageList1 
      Left            =   7560
      Top             =   720
      _ExtentX        =   1005
      _ExtentY        =   1005
      BackColor       =   -2147483643
      ImageWidth      =   17
      ImageHeight     =   17
      MaskColor       =   12632256
      _Version        =   393216
      BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
         NumListImages   =   3
         BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmNewType.frx":0000
            Key             =   ""
         EndProperty
         BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmNewType.frx":21DD
            Key             =   ""
         EndProperty
         BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
            Picture         =   "frmNewType.frx":3940
            Key             =   ""
         EndProperty
      EndProperty
   End
   Begin VB.PictureBox Picture1 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   225
      Left            =   9840
      Picture         =   "frmNewType.frx":3BD8
      ScaleHeight     =   225
      ScaleWidth      =   240
      TabIndex        =   29
      ToolTipText     =   "Help.."
      Top             =   120
      Width           =   240
   End
   Begin VB.CommandButton Command5 
      Caption         =   "Add a new type"
      Height          =   375
      Left            =   2520
      TabIndex        =   6
      Top             =   6600
      Width           =   1575
   End
   Begin VB.CommandButton Command3 
      Caption         =   "Remove selected type"
      Height          =   375
      Left            =   120
      TabIndex        =   28
      Top             =   6600
      Width           =   2295
   End
   Begin VB.Frame Frame3 
      Caption         =   "Filter"
      Height          =   735
      Left            =   360
      TabIndex        =   24
      Top             =   0
      Width           =   6015
      Begin VB.OptionButton Option1 
         Caption         =   "Receipt"
         Height          =   375
         Left            =   120
         TabIndex        =   27
         Top             =   240
         Width           =   1095
      End
      Begin VB.OptionButton Option2 
         Caption         =   "Expenditure"
         Height          =   255
         Left            =   1440
         TabIndex        =   26
         Top             =   300
         Value           =   -1  'True
         Width           =   1575
      End
      Begin VB.OptionButton Option5 
         Caption         =   "ALL"
         Height          =   375
         Left            =   3120
         TabIndex        =   25
         Top             =   300
         Width           =   1815
      End
   End
   Begin VB.CommandButton Command4 
      Caption         =   "&Select this one .."
      Height          =   375
      Left            =   5280
      TabIndex        =   22
      Top             =   1560
      Width           =   1575
   End
   Begin VB.TextBox txtSelect 
      Height          =   375
      Left            =   1080
      TabIndex        =   4
      Top             =   1560
      Width           =   3975
   End
   Begin VB.OptionButton optS 
      Caption         =   "Second half (S)"
      Height          =   255
      Left            =   4800
      TabIndex        =   3
      Top             =   1200
      Width           =   1695
   End
   Begin VB.OptionButton optF 
      Caption         =   "First half (F)"
      Height          =   255
      Left            =   3360
      TabIndex        =   2
      Top             =   1200
      Width           =   1335
   End
   Begin VB.ComboBox cboYear 
      Height          =   315
      Left            =   1080
      TabIndex        =   1
      Top             =   1200
      Width           =   2175
   End
   Begin VB.ComboBox cboOffice 
      Height          =   315
      Left            =   1080
      TabIndex        =   0
      Top             =   840
      Width           =   2175
   End
   Begin VB.Frame Frame2 
      Height          =   1215
      Left            =   120
      TabIndex        =   12
      Top             =   6960
      Width           =   9975
      Begin VB.CommandButton Command1 
         Caption         =   "Save"
         Height          =   375
         Left            =   8400
         TabIndex        =   9
         Top             =   240
         Width           =   1215
      End
      Begin VB.CommandButton Command6 
         Caption         =   "Cancel"
         Height          =   375
         Left            =   8400
         TabIndex        =   10
         Top             =   720
         Width           =   1215
      End
      Begin VB.TextBox txtDes 
         Height          =   375
         Left            =   5040
         TabIndex        =   8
         Top             =   720
         Width           =   3135
      End
      Begin VB.OptionButton optType 
         Caption         =   "Temporary Receipt-Invoice"
         Height          =   375
         Index           =   4
         Left            =   5160
         TabIndex        =   18
         Top             =   300
         Width           =   2295
      End
      Begin VB.OptionButton optType 
         Caption         =   "Budget"
         Height          =   375
         Index           =   3
         Left            =   4200
         TabIndex        =   17
         Top             =   300
         Width           =   855
      End
      Begin VB.TextBox txtType 
         Height          =   375
         Left            =   1560
         TabIndex        =   7
         Top             =   720
         Width           =   2175
      End
      Begin VB.OptionButton optType 
         Caption         =   "Expenditure"
         Height          =   255
         Index           =   1
         Left            =   1200
         TabIndex        =   15
         Top             =   360
         Value           =   -1  'True
         Width           =   1215
      End
      Begin VB.OptionButton optType 
         Caption         =   "Receipt"
         Height          =   375
         Index           =   0
         Left            =   240
         TabIndex        =   14
         Top             =   300
         Width           =   1215
      End
      Begin VB.OptionButton optType 
         Caption         =   "Money exchange"
         Height          =   375
         Index           =   2
         Left            =   2520
         TabIndex        =   13
         Top             =   300
         Width           =   1575
      End
      Begin VB.Label Label4 
         AutoSize        =   -1  'True
         Caption         =   "Type description"
         Height          =   195
         Left            =   3840
         TabIndex        =   23
         Top             =   720
         Width           =   1170
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "Enter new item"
         Height          =   195
         Left            =   360
         TabIndex        =   16
         Top             =   840
         Width           =   1050
      End
   End
   Begin MSComctlLib.ListView ListView1 
      Height          =   4455
      Left            =   120
      TabIndex        =   5
      Top             =   2040
      Width           =   9975
      _ExtentX        =   17595
      _ExtentY        =   7858
      View            =   3
      Arrange         =   2
      LabelEdit       =   1
      Sorted          =   -1  'True
      LabelWrap       =   -1  'True
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      GridLines       =   -1  'True
      _Version        =   393217
      ColHdrIcons     =   "ImageList1"
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      BorderStyle     =   1
      Appearance      =   1
      NumItems        =   3
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "Item"
         Object.Width           =   4304
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   1
         Text            =   "Type Description"
         Object.Width           =   7056
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         SubItemIndex    =   2
         Text            =   "Type For"
         Object.Width           =   2540
      EndProperty
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Close"
      Height          =   375
      Left            =   8520
      TabIndex        =   11
      Top             =   6600
      Width           =   1215
   End
   Begin VB.Label Label3 
      Caption         =   "Type"
      Height          =   255
      Left            =   360
      TabIndex        =   21
      Top             =   1680
      Width           =   495
   End
   Begin VB.Label Label2 
      Caption         =   "Year"
      Height          =   255
      Left            =   360
      TabIndex        =   20
      Top             =   1320
      Width           =   615
   End
   Begin VB.Label Office 
      Caption         =   "Office"
      Height          =   255
      Left            =   360
      TabIndex        =   19
      Top             =   840
      Width           =   855
   End
End
Attribute VB_Name = "frmNewType"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public BilltypeParameter As String
Public isSelect As Boolean
Dim formShow As Boolean
Private Sub cboOffice_Click()
SetSelecttextBox
End Sub

Private Sub cboYear_Click()
SetSelecttextBox
End Sub

Private Sub Command1_Click()
Dim sql As String
Dim rs As New ADODB.Recordset
Dim bill As String
Dim i, N As Integer
If Trim(txtType.Text) = "" Or Trim(txtDes.Text) = "" Then
    MsgBox "The Type and Desciption box can not be empty", vbInformation + vbOKOnly, "Message"
    Exit Sub
    
End If
If MsgBox("Do you want to add this Type (Y/N)", vbQuestion + vbYesNo + vbDefaultButton2, "Message") = vbNo Then
    Exit Sub
End If
For i = 0 To optType.Count - 1
    If optType(i).Value = True Then
        N = i
    End If
Next i
Select Case N
    Case 0
        bill = "RC"
    Case 1
        bill = "IV"
    Case 2
        bill = "ME"
    Case 3
        bill = "BF"
    Case 4
        bill = "TI"
End Select
sql = "select * from typelist where name ='" & txtType.Text & "' and bill='" & bill & "'"
Set rs = adoConnection.Execute(sql)
If Not rs.EOF Then
    MsgBox "This type already exists"
    txtType.SetFocus
    rs.Close
    Set rs = Nothing
    Exit Sub
End If
rs.Close
    Set rs = Nothing
sql = "insert into typelist(name,DES,bill) values('" & txtType.Text & "','" & txtDes.Text & "','" & bill & "')"
adoConnection.Execute (sql)
txtType.Text = ""
txtDes.Text = ""
Call displayUser
MsgBox "Save successfully", vbInformation + vbOKOnly, "Message"
'Call SetTypeValue(frmIncoice.cboType, BilltypeParameter)
End Sub

Private Sub Command2_Click()
Unload Me
End Sub

Private Sub Command3_Click()
Dim sql As String
Dim i As Integer
If ListView1.ListItems.Count <= 0 Then
    Exit Sub
End If


 
If Trim(ListView1.SelectedItem.Text) <> "" Then
    If MsgBox("Do you want to delete this item?(Y/N)", vbQuestion + vbYesNo + vbDefaultButton2, "Question") = vbNo Then
        Exit Sub
    End If
    sql = "Delete from typelist where name ='" & ListView1.SelectedItem.Text & "'"
    adoConnection.Execute (sql)
    displayUser
    
Else
    MsgBox "You must select atleast one item", vbInformation + vbOKOnly, "Message"
End If
'Call SetTypeValue(frmIncoice.cboType, BilltypeParameter)
End Sub

Private Sub Command4_Click()
If isSelect Then
If BilltypeParameter = "ESTIMATED" Then
    frmEstimatedExp.cboType.Text = txtSelect.Text
Else
    frmIncoice.cboType.Text = txtSelect.Text
End If
Unload Me
End If
End Sub

Private Sub Command5_Click()
If formShow Then
Me.Height = 7515
formShow = False
Command5.Enabled = True
Else
formShow = True
Me.Height = 8730
Command5.Enabled = False
End If
End Sub

Private Sub Command6_Click()
Command5.Enabled = True
formShow = False
Me.Height = 7515
End Sub

Private Sub Form_Load()
Dim rs As New ADODB.Recordset
Dim sql As String
formShow = False
Me.Height = 7515
Me.Top = Screen.Height / 2 - (Me.Height / 1.6)
    Me.Left = Screen.Width / 2 - (Me.Width / 2)
If BilltypeParameter <> "" Then
    If BilltypeParameter = "IV" Then
        Option2.Value = True
    ElseIf BilltypeParameter = "RC" Then
        Option1.Value = True
    
    Else
        Option5.Value = True
    End If
Else
    Option2.Value = True
End If
sql = "Select Distinct name from Office"
Set rs = adoConnection.Execute(sql)
While Not rs.EOF
    cboOffice.AddItem rs(0).Value
    rs.MoveNext
Wend
cboOffice.Text = "G" & stroffice
cboYear.AddItem "2008"
cboYear.AddItem "2009"
cboYear.AddItem "2010"

If Year(Now()) > 2010 Then
    For i = 2011 To Year(Now())
        cboYear.AddItem i
    Next i
End If
cboYear.Text = Year(Now())
 
displayUser
If Month(Now()) < 7 Then
    optF.Value = True
Else
    optS.Value = True
End If
If permit <> "A" Then
    Command3.Enabled = False
    Frame2.Enabled = False
    Command5.Enabled = False
ElseIf permit = "A" Then
    Command3.Enabled = True
    Frame2.Enabled = True
    Command5.Enabled = True
End If
End Sub

Public Function displayUser()
        Dim rs As ADODB.Recordset
        Dim sql As String
        Dim item
        Set rs = New ADODB.Recordset
        
        If Option2.Value Then
            sql = "Select * from typelist where bill ='IV' order by 1"
        ElseIf Option1.Value Then
            sql = "Select * from typelist where bill ='RC'order by 1"
        Else
            sql = "Select * from typelist order by 1"
        End If
        Set rs = adoConnection.Execute(sql)
        ListView1.ListItems.Clear
        Do While rs.EOF = False
            Set item = ListView1.ListItems.Add(, , rs!Name)
            item.SubItems(1) = rs!Des
            item.SubItems(2) = GetBillTypeDescription(rs!bill)
            
            rs.MoveNext
        Loop
        rs.Close
        Set rs = Nothing
        ListView1.ColumnHeaders(1).Icon = 2
End Function
Private Function SetSelecttextBox()
Dim fs As String
If Option2.Value = False Then
    Exit Function
End If
If optF.Value = True Then
    fs = "F"
ElseIf optS.Value = True Then
    fs = "S"
Else
    MsgBox "Please select First or Second financial year!", vbInformation + vbOKOnly, "Message"
    txtSelect.Text = ""
    Command4.Enabled = False
    Exit Function
End If

txtSelect.Text = ListView1.SelectedItem.Text & cboOffice.Text & Right(cboYear.Text, 2) & fs
If Len(txtSelect.Text) = 12 Then
    Command4.Enabled = True
Else
    Command4.Enabled = False
End If
End Function

Private Sub ListView1_Click()
SetSelecttextBox
End Sub

 

Private Sub ListView1_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
With ListView1
   ListView1.SortKey = ColumnHeader.Index - 1
    If ListView1.SortOrder = lvwAscending Then
        ListView1.SortOrder = lvwDescending
        .ColumnHeaders(1).Icon = 3
        .ColumnHeaders(2).Icon = 3
        .ColumnHeaders(3).Icon = 3
        ColumnHeader.Icon = 1
    Else
        ListView1.SortOrder = lvwAscending
        .ColumnHeaders(1).Icon = 3
        .ColumnHeaders(2).Icon = 3
        .ColumnHeaders(3).Icon = 3
        ColumnHeader.Icon = 2
    End If
    ListView1.Sorted = True
    
    
End With
End Sub
 

Private Sub ListView1_KeyUp(KeyCode As Integer, Shift As Integer)
SetSelecttextBox
End Sub

Private Sub optF_Click()
SetSelecttextBox
End Sub

Private Sub Option1_Click()
displayUser
End Sub

Private Sub Option2_Click()
displayUser
End Sub

Private Sub Option5_Click()
displayUser
End Sub

Private Sub optS_Click()
SetSelecttextBox
End Sub

